package paper.token;

public enum TT {
    AUTHOR, TITLE, AFFILIATION, WHERE,         // Bayesian
        NUMBER, EMAIL, DOT, KEY, EDITOR,  // Other classifications
        BOLD, NOTBOLD, ITALIC, NOTITALIC,      // Flags and Markers
        LARGE, NOTLARGE, FONTCHANGE, EOL, EOF,              
        UNKNOWN, RUBBISH;                      // Pseudo states

    public final static int nTT =  4;

    public boolean isBayesian() {
        return
            this == AUTHOR || this == TITLE ||
            this == AFFILIATION || this == WHERE;
    }

    public int intValue() {
        switch (this) {
        case AUTHOR: return 0;
        case TITLE: return 1;
        case AFFILIATION: return 2;
        case WHERE: return 3;
        }
        return -1;
    }

    public char toChar() {
        switch (this) {
        case AUTHOR:  return 'A';
        case TITLE:   return 'T';
        case AFFILIATION: return 'F';
        case WHERE:   return 'W';
        }
        return '?';
    }

    public static TT fromChar(char c) {
        switch (Character.toLowerCase(c)) {
        case 'A': return TT.AUTHOR;
        case 'T': return TT.TITLE;
        case 'F': return TT.AFFILIATION;
        case 'W': return TT.WHERE;
        }
        return TT.UNKNOWN;
    }
}
